package org.siam.impl.schemas {
	
	import org.siam.core.schemas.ISchemaProperty;
	import org.siam.core.schemas.ISchemaPropertyFactory;
	
	public class SchemaPropertyFactory implements ISchemaPropertyFactory {
		
		private var _configuration:XML;
		
		public function SchemaPropertyFactory(configuration:XML) {
			_configuration = configuration;
		}
		
		public function newInstance():ISchemaProperty {
			var instance:SchemaProperty = new SchemaProperty();
			
			for each (var attributeXML:XML in _configuration.attributes()) {
				var key:String = attributeXML.name();
				var value:String = attributeXML.toString();
				switch (key) {
					case "id": instance._id = value; break;
					case "formatter": instance._formatterId = value; break;
					case "renderer": instance._rendererId = value; break;
					default: instance.registerMetadata(key, value); break;
				}
			}
			
			return instance;
		}
	}
}